/**   
* @Title: Application.java
* @Package org.xaoyaoyao.cloud.mybatis
* @Description: TODO
* @author xaoyaoyao
* @date Feb 13, 2019 1:24:37 PM
* @version V1.0   
*/
package org.xaoyaoyao.cloud;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Import;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.xaoyaoyao.cloud.dynamic.aop.DynamicDataSourceAnnotationAdvisor;
import org.xaoyaoyao.cloud.dynamic.aop.DynamicDataSourceAnnotationInterceptor;
import org.xaoyaoyao.cloud.dynamic.source.DynamicDataSourceRegister;

/**
 * @ClassName: Application
 * @Description: TODO
 * @author xaoyaoyao
 * @date Feb 13, 2019 1:24:37 PM
 * 
 */
@Import(DynamicDataSourceRegister.class)
@SpringBootApplication
@ComponentScan(basePackages = { "org.xaoyaoyao.cloud" })
// 在启动类中添加对mapper包扫描@MapperScan
@MapperScan("org.xaoyaoyao.cloud.mybatis.mapper")
@EnableTransactionManagement
public class Application {

	@Bean
	public DynamicDataSourceAnnotationAdvisor dynamicDatasourceAnnotationAdvisor() {
		return new DynamicDataSourceAnnotationAdvisor(new DynamicDataSourceAnnotationInterceptor());
	}

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}
}
